# -*- coding: utf-8 -*-

import requests
from bs4 import BeautifulSoup

class keySearch(object):
    def __init__(self, *args, **kwargs):
        return super().__init__(*args, **kwargs)

    def __searchItem(self,itemName):
        wiki="https://ff14.huijiwiki.com/"
        req=requests.get('https'+'://cdn.huijiwiki.com/ff14/api.php?format='+
            'json&action=parse&disablelimitreport=true&prop=text&title=ItemSearch&ver=4.4&smaxage=86400&maxage=86400&'+
            'text={{ItemSearch|name='+itemName+'|job=0|kind=0|category=0|rarity=0}}')
        bf1=BeautifulSoup(req.text)
        bf=BeautifulSoup(str(bf1.contents[1]))
        itemList=[]
        fristFlag=True
        for each in bf.stripped_strings:
            if 'Lv' not in each:
                uniChange=each.encode('utf-8').decode('unicode_escape')
                if '符合条件的物品' in uniChange : 
                    itemList.append(uniChange)
                print(uniChange)
                if itemName in uniChange:
                    itemList.append(uniChange)
        #print(itemList)
        return itemList


    def work(self,item):
        #item=input("物品名称：")
        item=item.strip()
        return self.__searchItem(item)



if __name__ == '__main__':
    a=keySearch()
    #while(1):
    #item=input("物品名称：")
    item="獭獭"
    result=a.work(item)
    